/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
* FileSettingsDialog.java
*
* Created on January 2, 2008, 1:32 PM
 */
package gui.genomemap.settings;

import main.genomemap.DataIntegrityTest;

import java.awt.*;

import javax.swing.*;

/**
 *
 * @author  stewari1
 */
public class FileSettingsDialog extends javax.swing.JDialog {

    /** Field description */
    private int currentDisplayNum = 1;


    // Variables declaration - do not modify//GEN-BEGIN:variables

    /** Field description */
    private javax.swing.JButton backButton;

    /** Field description */
    private javax.swing.JPanel buttonPanel;

    /** Field description */
    private javax.swing.JButton cancelButton;

    /** Field description */
    private javax.swing.JCheckBox corrTest_JCheckBox;

    /** Field description */
    private javax.swing.JEditorPane dupCorrectionEditorPane;

    /** Field description */
    private javax.swing.JPanel dupCorrectionPanel;

    /** Field description */
    private javax.swing.JRadioButton dupCorrectionRButton;

    /** Field description */
    private javax.swing.JEditorPane dupTestEditorPane;

    /** Field description */
    private javax.swing.JPanel dupTestPanel;

    /** Field description */
    private javax.swing.JRadioButton dupTestRButton;

    /** Field description */
    private javax.swing.JCheckBox dupTest_JCheckBox;

    /** Field description */
    private javax.swing.JLabel fileDescLabel;

    /** Field description */
    private javax.swing.JPanel fileDescPanel;

    /** Field description */
    private javax.swing.JPanel fileFmtTestDescPanel;

    /** Field description */
    private javax.swing.JEditorPane fileFormatTestEditorPane;

    /** Field description */
    private javax.swing.JRadioButton fileFormatTestRButton;

    /** Field description */
    private javautil.swing.components.FlexTextArea flexTextArea;

    /** Field description */
    private javax.swing.JCheckBox formatTest_JCheckBox;

    /** Field description */
    private javax.swing.JLabel integrityTestDescLabel;

    /** Field description */
    private javax.swing.JPanel integrityTestDescPanel;

    /** Field description */
    private javax.swing.JEditorPane jEditorPane1;

    /** Field description */
    private javax.swing.JScrollPane jScrollPane1;

    /** Field description */
    private javax.swing.JScrollPane jScrollPane2;

    /** Field description */
    private javax.swing.JScrollPane jScrollPane3;

    /** Field description */
    private javax.swing.JScrollPane jScrollPane4;

    /** Field description */
    private javax.swing.JPanel mainPanel;

    /** Field description */
    private javax.swing.JButton nextButton;

    /** Field description */
    private javax.swing.JPanel runTestsPanel;

    /** Field description */
    private javautil.swing.components.ShortProgressPanel shortProgressPanel;

    /** Field description */
    private javax.swing.JPanel testDescHolderPanel;

    /** Field description */
    private javax.swing.ButtonGroup testDescbuttonGroup;


    // End of variables declaration//GEN-END:variables

    /** Creates new form FileSettingsDialog */
    public FileSettingsDialog(java.awt.Frame parent, boolean modal) {

        super(parent, modal);

        initComponents();
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */


    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {

        testDescbuttonGroup      = new javax.swing.ButtonGroup();
        buttonPanel              = new javax.swing.JPanel();
        backButton               = new javax.swing.JButton();
        nextButton               = new javax.swing.JButton();
        cancelButton             = new javax.swing.JButton();
        mainPanel                = new javax.swing.JPanel();
        fileDescPanel            = new javax.swing.JPanel();
        fileDescLabel            = new javax.swing.JLabel();
        jScrollPane1             = new javax.swing.JScrollPane();
        jEditorPane1             = new javax.swing.JEditorPane();
        integrityTestDescPanel   = new javax.swing.JPanel();
        integrityTestDescLabel   = new javax.swing.JLabel();
        fileFormatTestRButton    = new javax.swing.JRadioButton();
        dupTestRButton           = new javax.swing.JRadioButton();
        dupCorrectionRButton     = new javax.swing.JRadioButton();
        testDescHolderPanel      = new javax.swing.JPanel();
        fileFmtTestDescPanel     = new javax.swing.JPanel();
        jScrollPane2             = new javax.swing.JScrollPane();
        fileFormatTestEditorPane = new javax.swing.JEditorPane();
        dupTestPanel             = new javax.swing.JPanel();
        jScrollPane3             = new javax.swing.JScrollPane();
        dupTestEditorPane        = new javax.swing.JEditorPane();
        dupCorrectionPanel       = new javax.swing.JPanel();
        jScrollPane4             = new javax.swing.JScrollPane();
        dupCorrectionEditorPane  = new javax.swing.JEditorPane();
        runTestsPanel            = new javax.swing.JPanel();
        formatTest_JCheckBox     = new javax.swing.JCheckBox();
        dupTest_JCheckBox        = new javax.swing.JCheckBox();
        corrTest_JCheckBox       = new javax.swing.JCheckBox();
        shortProgressPanel       = new javautil.swing.components.ShortProgressPanel();
        flexTextArea             = new javautil.swing.components.FlexTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        backButton.setText("Back");
        backButton.setEnabled(false);
        backButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }

        });
        nextButton.setText("Next");
        nextButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }

        });
        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }

        });

        javax.swing.GroupLayout buttonPanelLayout = new javax.swing.GroupLayout(buttonPanel);

        buttonPanel.setLayout(buttonPanelLayout);
        buttonPanelLayout.setHorizontalGroup(
            buttonPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                buttonPanelLayout.createSequentialGroup().addContainerGap(
                    343, Short.MAX_VALUE).addComponent(backButton).addPreferredGap(
                    javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                    nextButton).addPreferredGap(
                    javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                    cancelButton).addContainerGap()));
        buttonPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, backButton, cancelButton,
                                   nextButton);
        buttonPanelLayout.setVerticalGroup(
            buttonPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                buttonPanelLayout.createSequentialGroup().addContainerGap(
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(
                    buttonPanelLayout.createParallelGroup(
                        javax.swing.GroupLayout.Alignment.BASELINE).addComponent(
                        backButton).addComponent(nextButton).addComponent(
                        cancelButton)).addContainerGap()));
        mainPanel.setLayout(new java.awt.CardLayout());
        fileDescLabel.setText(
            "<html>\nBefore proceeding to the next screen, please have the files ready<br>\nwith the naming pattern as described in the following specification.\n</html>");
        jScrollPane1.setViewportView(jEditorPane1);

        javax.swing.GroupLayout fileDescPanelLayout = new javax.swing.GroupLayout(fileDescPanel);

        fileDescPanel.setLayout(fileDescPanelLayout);
        fileDescPanelLayout.setHorizontalGroup(
            fileDescPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                fileDescPanelLayout.createSequentialGroup().addContainerGap().addGroup(
                    fileDescPanelLayout.createParallelGroup(
                        javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                        jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 502,
                        javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(
                            fileDescLabel)).addContainerGap(48, Short.MAX_VALUE)));
        fileDescPanelLayout.setVerticalGroup(
            fileDescPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                fileDescPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    fileDescLabel).addGap(15, 15, 15).addComponent(
                    jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 320,
                    javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(75, Short.MAX_VALUE)));
        mainPanel.add(fileDescPanel, "1");
        integrityTestDescLabel.setText(
            "<html>\nThe necessary files are all present in the required directory.<br><br>\nThe following integrity tests will be applied to the collection of <br>\ninput files before this collection can be treated as a <b> File Setting</b>\nfor this application. <br><br>\nTo learn more about the description of each test<br>\nselect them below.\n</html>");
        testDescbuttonGroup.add(fileFormatTestRButton);
        fileFormatTestRButton.setSelected(true);
        fileFormatTestRButton.setText("<html>\n<b>File Format Integrity Test</b>\n</html>");
        fileFormatTestRButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        fileFormatTestRButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        fileFormatTestRButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileFormatTestRButtonActionPerformed(evt);
            }

        });
        testDescbuttonGroup.add(dupTestRButton);
        dupTestRButton.setText("<html>\n<b>Clone/Probe Duplicay Test</b>\n</html>");
        dupTestRButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        dupTestRButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        dupTestRButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dupTestRButtonActionPerformed(evt);
            }

        });
        testDescbuttonGroup.add(dupCorrectionRButton);
        dupCorrectionRButton.setText("<html>\n<b>Duplicay Correction Test</b>\n</html>");
        dupCorrectionRButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        dupCorrectionRButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        dupCorrectionRButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dupCorrectionRButtonActionPerformed(evt);
            }

        });
        testDescHolderPanel.setLayout(new java.awt.CardLayout());
        testDescHolderPanel.setBorder(
            javax.swing.BorderFactory.createTitledBorder("Test Description"));
        fileFmtTestDescPanel.setBorder(
            javax.swing.BorderFactory.createTitledBorder("File Format Integrity Test Description"));
        fileFormatTestEditorPane.setContentType("text/html");
        jScrollPane2.setViewportView(fileFormatTestEditorPane);

        javax.swing.GroupLayout fileFmtTestDescPanelLayout =
            new javax.swing.GroupLayout(fileFmtTestDescPanel);

        fileFmtTestDescPanel.setLayout(fileFmtTestDescPanelLayout);
        fileFmtTestDescPanelLayout.setHorizontalGroup(
            fileFmtTestDescPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                fileFmtTestDescPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 488,
                    Short.MAX_VALUE).addContainerGap()));
        fileFmtTestDescPanelLayout.setVerticalGroup(
            fileFmtTestDescPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                fileFmtTestDescPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 212,
                    Short.MAX_VALUE).addContainerGap()));
        testDescHolderPanel.add(fileFmtTestDescPanel, "1");
        dupTestPanel.setBorder(
            javax.swing.BorderFactory.createTitledBorder("Clone/Probe Duplicacy Test Description"));
        dupTestEditorPane.setContentType("text/html");
        jScrollPane3.setViewportView(dupTestEditorPane);

        javax.swing.GroupLayout dupTestPanelLayout = new javax.swing.GroupLayout(dupTestPanel);

        dupTestPanel.setLayout(dupTestPanelLayout);
        dupTestPanelLayout.setHorizontalGroup(
            dupTestPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                dupTestPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 488,
                    Short.MAX_VALUE).addContainerGap()));
        dupTestPanelLayout.setVerticalGroup(
            dupTestPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                dupTestPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 212,
                    Short.MAX_VALUE).addContainerGap()));
        testDescHolderPanel.add(dupTestPanel, "2");
        dupCorrectionPanel.setBorder(
            javax.swing.BorderFactory.createTitledBorder("Duplicacy Correction Test Description"));
        dupCorrectionEditorPane.setContentType("text/html");
        jScrollPane4.setViewportView(dupCorrectionEditorPane);

        javax.swing.GroupLayout dupCorrectionPanelLayout =
            new javax.swing.GroupLayout(dupCorrectionPanel);

        dupCorrectionPanel.setLayout(dupCorrectionPanelLayout);
        dupCorrectionPanelLayout.setHorizontalGroup(
            dupCorrectionPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                dupCorrectionPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 488,
                    Short.MAX_VALUE).addContainerGap()));
        dupCorrectionPanelLayout.setVerticalGroup(
            dupCorrectionPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                dupCorrectionPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 212,
                    Short.MAX_VALUE).addContainerGap()));
        testDescHolderPanel.add(dupCorrectionPanel, "3");

        javax.swing.GroupLayout integrityTestDescPanelLayout =
            new javax.swing.GroupLayout(integrityTestDescPanel);

        integrityTestDescPanel.setLayout(integrityTestDescPanelLayout);
        integrityTestDescPanelLayout.setHorizontalGroup(
            integrityTestDescPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                integrityTestDescPanelLayout.createSequentialGroup().addContainerGap().addGroup(
                    integrityTestDescPanelLayout.createParallelGroup(
                        javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                        testDescHolderPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 540,
                        Short.MAX_VALUE).addComponent(
                            integrityTestDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 406,
                            javax.swing.GroupLayout.PREFERRED_SIZE).addGroup(
                                integrityTestDescPanelLayout.createSequentialGroup().addComponent(
                                    fileFormatTestRButton).addPreferredGap(
                                    javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                    dupTestRButton).addPreferredGap(
                                    javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                    dupCorrectionRButton))).addContainerGap()));
        integrityTestDescPanelLayout.setVerticalGroup(
            integrityTestDescPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                integrityTestDescPanelLayout.createSequentialGroup().addContainerGap().addComponent(
                    integrityTestDescLabel).addGap(14, 14, 14).addGroup(
                    integrityTestDescPanelLayout.createParallelGroup(
                        javax.swing.GroupLayout.Alignment.BASELINE).addComponent(
                        fileFormatTestRButton).addComponent(dupTestRButton).addComponent(
                        dupCorrectionRButton)).addPreferredGap(
                            javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            testDescHolderPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 294,
                            Short.MAX_VALUE).addContainerGap()));
        mainPanel.add(integrityTestDescPanel, "2");
        formatTest_JCheckBox.setText("<html>\n<b>File Format Integrity Test</b>\n</html>");
        formatTest_JCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        formatTest_JCheckBox.setEnabled(false);
        formatTest_JCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        dupTest_JCheckBox.setText("<html>\n<b>Clone/Probe Duplicay Test</b>\n</html>");
        dupTest_JCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        dupTest_JCheckBox.setEnabled(false);
        dupTest_JCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
        corrTest_JCheckBox.setText("<html>\n<b>Duplicay Correction</b>\n</html>");
        corrTest_JCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        corrTest_JCheckBox.setEnabled(false);
        corrTest_JCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));

        javax.swing.GroupLayout runTestsPanelLayout = new javax.swing.GroupLayout(runTestsPanel);

        runTestsPanel.setLayout(runTestsPanelLayout);
        runTestsPanelLayout.setHorizontalGroup(
            runTestsPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                runTestsPanelLayout.createSequentialGroup().addContainerGap().addGroup(
                    runTestsPanelLayout.createParallelGroup(
                        javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                        shortProgressPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 540,
                        Short.MAX_VALUE).addComponent(
                            flexTextArea, javax.swing.GroupLayout.PREFERRED_SIZE, 500,
                            javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(
                                formatTest_JCheckBox).addComponent(dupTest_JCheckBox).addComponent(
                                corrTest_JCheckBox)).addContainerGap()));
        runTestsPanelLayout.setVerticalGroup(
            runTestsPanelLayout.createParallelGroup(
                javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                runTestsPanelLayout.createSequentialGroup().addGap(24, 24, 24).addComponent(
                    formatTest_JCheckBox).addPreferredGap(
                    javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                    dupTest_JCheckBox).addPreferredGap(
                    javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                    corrTest_JCheckBox).addGap(16, 16, 16).addComponent(
                    shortProgressPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                    javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                        flexTextArea, javax.swing.GroupLayout.DEFAULT_SIZE, 298,
                        Short.MAX_VALUE).addContainerGap()));
        mainPanel.add(runTestsPanel, "3");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                buttonPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(
                    mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE));
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addComponent(
                    mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 449,
                    Short.MAX_VALUE).addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                        buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)));
        pack();

    }    // </editor-fold>//GEN-END:initComponents

    /**
     * Method description
     *
     * @param evt description
     */
    private void dupCorrectionRButtonActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_dupCorrectionRButtonActionPerformed

        CardLayout cl = (CardLayout) (testDescHolderPanel.getLayout());

        cl.show(testDescHolderPanel, "3");

    }    // GEN-LAST:event_dupCorrectionRButtonActionPerformed

    /**
     * Method description
     *
     * @param evt description
     */
    private void dupTestRButtonActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_dupTestRButtonActionPerformed

        CardLayout cl = (CardLayout) (testDescHolderPanel.getLayout());

        cl.show(testDescHolderPanel, "2");


        // @todo load html description from an external file using a method from FileSettings

    }    // GEN-LAST:event_dupTestRButtonActionPerformed

    /**
     * Method description
     *
     * @param evt description
     */
    private void fileFormatTestRButtonActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_fileFormatTestRButtonActionPerformed

        CardLayout cl = (CardLayout) (testDescHolderPanel.getLayout());

        cl.show(testDescHolderPanel, "1");

    }    // GEN-LAST:event_fileFormatTestRButtonActionPerformed

    /**
     * Method description
     *
     * @param evt description
     */
    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_cancelButtonActionPerformed
        dispose();
    }    // GEN-LAST:event_cancelButtonActionPerformed

    /**
     * Method description
     *
     * @param evt description
     */
    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_nextButtonActionPerformed

        if (nextButton.getText().equals("Finish")) dispose();


        // determine next card to display
        CardLayout cl = (CardLayout) (mainPanel.getLayout());
        String card   = String.valueOf(currentDisplayNum + 1);

        if (currentDisplayNum == 1) {


            // need to show second screen: integrity Test Desc
            // enable back button
            backButton.setEnabled(true);
        } else if (currentDisplayNum == 2) {


            // need to show 3rd screen - Ready to Run the tests :
            nextButton.setText("Run");
        } else if (currentDisplayNum == 3) {


            // time to finish the task
            final DataIntegrityTest dataIntegrityTest = new DataIntegrityTest();

            dataIntegrityTest.addPropertyChangeListener(shortProgressPanel);
            dataIntegrityTest.addPropertyChangeListener(flexTextArea);

            SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

                public Void doInBackground() {

                    if (dataIntegrityTest.runTests()) {

                        shortProgressPanel.setStatusInfo("All the tests have been passed.");
                        formatTest_JCheckBox.setSelected(true);
                        dupTest_JCheckBox.setSelected(true);
                        corrTest_JCheckBox.setSelected(true);

                    } else {

                        shortProgressPanel.setStatusInfo("The test failed.");

                        if (dataIntegrityTest.isFormatTestPassed())
                            formatTest_JCheckBox.setSelected(true);
                    }


                    // disable back button and set the test to "Finish"
                    shortProgressPanel.setShowProgress(false);
                    backButton.setEnabled(false);
                    nextButton.setText("Finish");

                    return null;
                }
            };

            worker.execute();
        }


        // show card
        cl.show(mainPanel, card);


        // update display number
        currentDisplayNum++;

    }    // GEN-LAST:event_nextButtonActionPerformed

    /**
     * Method description
     *
     * @param evt description
     */
    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_backButtonActionPerformed


        // determine previous card to display
        CardLayout cl = (CardLayout) (mainPanel.getLayout());
        String card   = String.valueOf(currentDisplayNum - 1);

        if (currentDisplayNum == 3) {


            // need to show second screen
            nextButton.setText("Next");
        } else if (currentDisplayNum == 2) {


            // need to show first screen - disable back button
            backButton.setEnabled(false);
        } else if (currentDisplayNum == 1) {


            // we are on first screen, nothing to do
        }


        // show card
        cl.show(mainPanel, card);


        // update display number for non-1 numbers
        currentDisplayNum = (currentDisplayNum > 1) ? (--currentDisplayNum) : 1;
    }    // GEN-LAST:event_backButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FileSettingsDialog(new javax.swing.JFrame(), true).setVisible(true);
            }

        });
    }
}
